<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    
</body>
<script>
    // 创建成功的promise对象
    let success = Promise.resolve("买牛肉");

    // 创建失败的promise对象
    let failed = Promise.reject("失败");



    // failed.then(null,res => {
    //     console.log(res);
    // })

    // catch是then(null,function())的语法糖
    failed.catch(res => {
        console.log(res);
    });

    // 瀑布流
    success.then(res=> {
        console.log(res);
        return "买猪肉";
    }).then(res => {
        console.log(res);
        return "买鸡肉";
    }).then(res => {
        console.log(res);
        return "买羊肉";
    }).then(res => {
        console.log(res);
        return Promise.reject("没钱了");
    }).catch(res => {
        console.log(res);
    })

</script>
</html>